package com.eogo.user.mapper;

import com.eogo.user.vo.UserVo;
import org.apache.ibatis.jdbc.SQL;


public class UserProvider {

    public String queryUserList(UserVo userVo){
        return new SQL(){
            {
                SELECT("u.id,u.account,u.username,u.age,u.phone,u.qq,u.weixin,u.email,u.sex,u.birthday,u.created");
                FROM("tb_user u");
                if(null != userVo.getId() && !"".equals(userVo.getId())){
                    WHERE(" u.id = #{id} ");
                }
                if(null != userVo.getUsername() && !"".equals(userVo.getUsername())){
                    WHERE(" u.username = #{username} ");
                }
                if(null != userVo.getAddress()&& !"".equals(userVo.getAddress())){
                    WHERE(" u.address = #{address} ");
                }
                if(null != userVo.getPhone()&& !"".equals(userVo.getPhone())){
                    WHERE(" u.phone = #{phone} ");
                }
                if(null != userVo.getEmail()&& !"".equals(userVo.getEmail())){
                    WHERE(" u.email = #{email} ");
                }
                if(null != userVo.getQq()&& !"".equals(userVo.getQq())){
                    WHERE(" u.qq = #{qq} ");
                }
                if(null != userVo.getWeixin()&& !"".equals(userVo.getWeixin())){
                    WHERE(" u.weixin = #{weixin} ");
                }
                if(null != userVo.getSex()&& !"".equals(userVo.getSex())){
                    WHERE(" u.sex = #{sex} ");
                }
                if(null != userVo.getAccount()&& !"".equals(userVo.getAccount())){
                    WHERE(" u.account = #{account} ");
                }
                if(null != userVo.getBirthday()&& !"".equals(userVo.getBirthday())){
                    WHERE(" u.birthday = #{birthday} ");
                }

            }
        }.toString();
    }
}
